package com.wyz.rabbitmqdomo.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    @Bean
    public FanoutExchange getFanoutExchange(){
        return new FanoutExchange("fanout_order_exchange", true, false);
    }

    @Bean
    public Queue getSmsQueue(){
        return new Queue("sms.fanout.queue", true);
    }

    @Bean
    public Queue getEmailQueue(){
        return new Queue("email.fanout.queue", true);
    }

    @Bean
    public Queue getDxQueue(){
        return new Queue("dx.fanout.queue", true);
    }

    @Bean
    public Binding getSmsBinding(){
        return BindingBuilder.bind(getSmsQueue()).to(getFanoutExchange());
    }

    @Bean
    public Binding getEmailBinding(){
        return BindingBuilder.bind(getEmailQueue()).to(getFanoutExchange());
    }

    @Bean
    public Binding getDxBinding(){
        return BindingBuilder.bind(getDxQueue()).to(getFanoutExchange());
    }

}
